<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"></meta>
<html>
	<%@taglib prefix="s" uri="/struts-tags"%>
	<head>
		<title>密码修改</title>
		<link
			href="<%=application.getContextPath()%>/nresources/ued/css/all-src.css"
			type="text/css" rel="stylesheet" />
		<jsp:include page="/WEB-INF/ibnms/common/configinclude.jsp"></jsp:include>
		<script type="text/javascript">
 	var oldPass=true;
 	var messageConfig;
 	$(document).ready(function(){
 		$('#personTab').tabs({  
		    border:false,  
		    onSelect:function(title,index){
		    	var $selectObj = $('#personTab').tabs("getTab",index);
		    	if($selectObj.html() == ""){
		    	}
		    }
		});
		/*实现密码修改--start*/
		$('#password-submit').click(function(e){
			var value = $("input[name='theForm.old_password']").val();
			var newPword = $("#newPassword").val();
			var newPwordConfirm = $("#passwordConfirm").val();
			var param = "theForm.password="+value;
			// 使用同步加载方法，将判断结果返回
			$.ajax({
				url:"checkOldPasswordValid.do",
				data:param,
				async:false,
				cache:false, 
			    success:function(msg){
			      if(msg=='false'){
			      	//$("#dd").focus();
			      	$.messager.alert('旧密码有误','旧密码错误，请重新输入!');
			      }
			   	  oldPass=msg;
			   	}
			});
			if(oldPass=='false')
				return ;
				
			if(newPword=='' || newPwordConfirm==''){
				$.messager.alert('密码重置错误','新密码与密码确认不能为空，请输入!');
				return ;
			}
			if(newPwordConfirm != newPword){
				$.messager.alert('密码重置错误','两次输入的密码不匹配,请重新输入!');
				return ;
			}
			// 确认无误后提交
			$('#passwordform').form('submit',{
				url:'changePassword.do',
				onSubmit:function(param){
					$('#password-submit').linkbutton('disable');
					var valrst = $('#passwordform').form('validate');
					var returnRst = eval(valrst)&&oldPass;
					return returnRst=='true'?true:false;
				},
				success: function(data){
					$.messager.confirm('密码修改成功','“确认”关闭配置窗口，“返回”操作其它设置！',function(r){  
					    if(r){
					       // 调用父页面的窗口关闭方法
					       $("#personalize").dialog('close');
					    }else{
					    	$('#password-submit').linkbutton('enable');
					    }
					});
				}
			});  
		});
		
		$('#password-reset').click(function(){
			$('#passwordform').form('reset');
		});
		
		$.extend($.messager.defaults,{
			ok:"确定",
			cancel:"返回"
		});
		
	    $.extend($.fn.validatebox.defaults.rules, {  
	        passwordCheck: {  
	            validator: function(value, param){
	            	var newpassword = $('input[name="theForm.password"]').val();
	            	if(newpassword==value){
	            		return true;
	            	}else{
	            		return false;
	            	}
	            },  
	            message: '您确认的密码有误，请重新输入！'  
	        },
	        minLength: {  
		        validator: function(value, param){  
		            return value.length >= param[0];  
		        },  
		        message: '密码至少为{0}个字符组成.'  
		    },
		    oldPwdCheck:{
		    	validator: function(value,param){
		    		return oldPass;
		    	},
		    	message:'您输入的旧密码与当前用户密码不匹配，请重新输入！'
		    }
		    
	    }); 
	    /*实现密码修改--end*/
	    
	    /*实现个人信息修改--start*/
	    $("#personinfo-submit").click(function(){
	    	$("#personinfoform").form('submit',{
	    		url:'modifyPersonInfo.do',
	    		onSubmit:function(){
					return $('#personinfoform').form('validate');
	    		},
	    		success:function(data){
	    			var rst = eval("("+data+")");
	    			if(rst.result=='true'){
		    			$.messager.confirm('个人信息修改成功','“确认”关闭配置窗口，“返回”操作其它设置！',function(r){  
						    if(r){
						       // 调用父页面的窗口关闭方法
						       $("#personalize").dialog('close');
						    }  
						});
					}else{
						$.messager.alert('网络故障，请稍后再试！',data);
					}
	    		}
	    	});
	    });
	    
	    $("#personinfo-reset").click(function(){
	    	$("#personinfoform").form('reset');
	    });
	    /*实现个人信息修改--end*/
	    
	    /*实现portal配置--start*/
	    $("a[rel='layoutset']").click(function(){
    		var $imgObj = $(this).find("img");
    		var imgsrc = $imgObj.attr("src");
    		var imgswap = $imgObj.attr("swap");
    		$("a[rel='layoutset'] > img").each(function(){
    			var $imgEle = $(this);
    			var imgEleSrc = $imgEle.attr("src");
    			var imgEleSwap = $imgEle.attr("swap");
    			if(imgEleSrc.toString().indexOf("_highlight.gif")>0){
                	$imgEle.attr("src",imgEleSwap);
                	$imgEle.attr("swap",imgEleSrc);
                }
    		});
    		$imgObj.attr("src",imgswap);
    		$imgObj.attr("swap",imgsrc);
    	});
    	// 初始化
    	$("a[rel='layoutset'] > img").each(function(){
    		var defaultImg = 'edit_this_tab_layoutimg_'+'<s:property value="layout.LAYOUT_ID" />';
  			var $imgEle = $(this);
  			var imgEleSrc = $imgEle.attr("src");
  			var imgEleSwap = $imgEle.attr("swap");
  			var imgEleValue = $imgEle.attr("id");
  			if(defaultImg==imgEleValue){
              	$imgEle.attr("src",imgEleSwap);
              	$imgEle.attr("swap",imgEleSrc);
              }
  		});
  		
  		var userSettingVals = $("#userSettingVal").val().split(";");
  		// 初始化checkbox
    	$("input[name='porletId']").each(function(){
    		var $checkObj = $(this);
    		$.each(userSettingVals,function(idx,value){
    			var colEles = value.split(",");
    			for(var i = 0 ; i < colEles.length ; i ++){
	    			if($checkObj.val() == colEles[i]){
		    			$checkObj.attr("checked","checked");
		    			break;
		    		}
	    		}
    		});
    	});
	    
	    $("#portal-submit").click(function(){
	    	/*提交时验证是否选择panel样式*/
	    	var isSelect = false;
	    	var layoutId;
	    	$("a[rel='layoutset'] > img").each(function(){
    			var $imgEle = $(this);
    			var imgEleSrc = $imgEle.attr("src");
    			var imgEleSwap = $imgEle.attr("swap");
    			if(imgEleSrc.toString().indexOf("_highlight.gif")>0){
                	isSelect = true;
                	layoutId = $imgEle.attr("val");
                }
    		});
    		if(!isSelect){
    			$.messager.alert('未选择提示','请设置布局！');
    			return false;
    		}
    		
    		var menuType = $("input[name='menuType']:checked").val();
    		if(menuType == undefined){
    			$.messager.alert('未选择提示','请选择菜单样式！');
		    	return false;
		    }
		    
    		var panelCollect = "";
    		$("input[name='porletId']:checked").each(function(){
    			panelCollect += ";"+ $(this).val();
    		});
    		
    		var param = "portalForm.PANEL_ID="+layoutId+"&portalForm.PANEL_COLLECT="+(panelCollect.substring(1))+"&portalForm.menuType="+menuType;
    		/**/
    		$("#portalform").form('submit',{
	    		url:'saveUserSetting.do?'+param,
	    		success:function(data){
	    			var rst = eval("("+data+")");
	    			if(rst.result==true){
		    			$.messager.confirm('个人portal修改成功','“确认”关闭配置窗口，“返回”操作其它设置，重新登录系统配置生效!',function(r){  
						    if(r){
						       // 调用父页面的窗口关闭方法
						       $("#personalize").dialog('close');
						    }  
						});
					}else{
						$.messager.alert('网络故障，请稍后再试！',data);
					}
	    		}
	    	});
	    });
	    
	    $("#portal-reset").click(function(){
	    	$("#portalform").form('reset');
	    });
	    
	    /*实现portal配置--end*/
	    /*实现消息显示设置--start*/
	    $("input[rel='displayType']").click(function(e){
	    	var $target = $(e.target);
	    	$("input[rel='displayType']").each(function(){
	    		$(this).removeAttr("checked");
	    	});
	    	if($target.val()=='1'){
    			$("[rel='display-interval']").show();
    		}else{
    			$("[rel='display-interval']").hide();
    		}
	    	$target.attr("checked","checked");
	    });
	    
	    $("a[name='subtract']").click(function(){
	    	var rel = $(this).attr("rel");
	    	var $countObj = $("#"+rel);
	    	var defaultVal = $(this).attr("default");
	    	var value = $countObj.val();
	    	if(value == defaultVal){
	    		return;
	    	}
	    	$countObj.val(parseInt(value)-1);
	    });
	    
	    $("a[name='add']").click(function(){
	    	var rel = $(this).attr("rel");
	    	var $countObj = $("#"+rel);
	    	var value = $countObj.val();
	    	$countObj.val(parseInt(value)+1);
	    });
	    
	    var loadMessageSetting = function(){
		    $.ajax({
		    	url:"queryMessageSetting.do",
		    	type:"post",
		    	success:function(data){
	    			messageConfig = data;
	    			messageReset();
		    	}
		    });
	    }
	    $("#msg-submit").click(function(){
	    	$("#msgDisplayform").form('submit',{
	    		url:"updateMessageSetting.do",
	    		success:function(data){
	    			if(data=='"true"'){
		    			$.messager.confirm('消息设置成功','“确认”关闭配置窗口，“返回”操作其它设置，重新登录系统配置生效!',function(r){  
						    if(r){
						       // 调用父页面的窗口关闭方法
						       $("#personalize").dialog('close');
						    }  
						});
					}else{
						$.messager.alert('网络故障，请稍后再试！',data);
					}
	    		}
	    	})
	    });
	    
	    var messageReset = function(){
	    	$("input[rel='displayType']").each(function(){
	    		if($(this).val()==messageConfig.display_type){
	    			$(this).attr("checked","checked");
	    		}
	    	});
	    	if(messageConfig.display_type=='1'){
	    		$("[rel='display-interval']").show();
	    	}else{
	    		$("[rel='display-interval']").hide();
	    	}
	    	$("#displayInterval option").each(function(){
	    		if($(this).val()==messageConfig.display_interval){
	    			$(this).attr("selected","selected");
	    		}
	    	});
	    	
	    	$("#displaySum").val(messageConfig.display_sum);
	    	$("#displayScope").val(messageConfig.display_scope);
	    }
	    
	    $("#msg-reset").click(function(){
	    	messageReset();
	    });
	    
	    loadMessageSetting();
	    /*实现消息显示设置--end*/
 	});	
 </script>
	</head>

	<body>
		<div id="personTab" class="easyui-tabs" data-options="fit:true">
				<div title="密码修改" style="padding: 0px;">
				<div class="form-wrapper">
					<form id="passwordform" method="post">
						<table class="table-03">
							<tr>
								<td>  
									用户名:  
								</td>
								<td>
									<input type="text" name="theForm.name"
										value="<s:property value="theForm.userName"/>"
										data-options="required:true" disabled="disabled"></input>
								</td>
							</tr>
							<tr>
								<td>
									旧密码:
								</td>
								<td>
									<input type="password" name="theForm.old_password"
										data-options="required:true,height:'10px',missingMessage:'必填项'"></input>
									<a id="dd" href="javascript:void(0)" class="easyui-tooltip"
										data-options=" 
				                    	showEvent: 'focus',
				                    	position:'right', 
				                    	deltaX:150,
				                    	height:'10px',
					                    hideEvent: 'none',  
					                    content: function(){  
					                        return '旧密码有误，请重新输入';  
					                    },  
					                    onShow: function(){  
					                        var t = $(this);  
					                        t.tooltip('tip').focus().unbind().bind('blur',function(){  
					                            t.tooltip('hide');  
					                        });  
					                    }  
					                ">
									</a>
								</td>
							</tr>
							<tr>
								<td>
									新密码
								</td>
								<td>
									<input type="password" id="newPassword" name="theForm.password"
										class="validate[required]"></input>
								</td>
							</tr>
							<tr>
								<td>
									新密码确认:
								</td>
								<td>
									<input type="password" id="passwordConfirm"
										name="new_password2" class="validate[required]"></input>
								</td>
							</tr>
						</table>
					</form>
					<div class="block03">
						<a id="password-submit" href="javascript:void(0)"
							class="easyui-linkbutton">提交</a>
						<a id="password-reset" href="javascript:void(0)"
							class="easyui-linkbutton">重置</a>
					</div>
				</div>
			</div>
			<div title="个人信息修改" style="overflow: auto; padding: 0px;">
				<div class="form-wrapper">
					<form id="personinfoform" method="post">
						<table class="table-03">
							<tr>
								<td>
									手机号:
								</td>
								<td>
									<input class="easyui-validatebox" type="text"
										name="theForm.telphone"
										value="<s:property value="theForm.telphone"/>"
										data-options="required:true,missingMessage:'必填项'"></input>
								</td>
							</tr>
							<tr>
								<td>
									固定电话:
								</td>
								<td>
									<input class="easyui-validatebox" type="text"
										name="theForm.local_phone"
										value="<s:property value="theForm.local_phone"/>"></input>
								</td>
							</tr>
							<tr>
								<td>
									邮件信箱
								</td>
								<td>
									<input class="easyui-validatebox" type="text"
										name="theForm.email"
										value="<s:property value="theForm.email"/>"
										data-options="required:true,missingMessage:'必填项',invalidMessage:'邮件格式不正确！',validType:'email'"></input>
								</td>
							</tr>
						</table>
					</form>
					<div class="block03">
						<a id="personinfo-submit" href="javascript:void(0)"
							class="easyui-linkbutton">提交</a>
						<a id="personinfo-reset" href="javascript:void(0)"
							class="easyui-linkbutton">重置</a>
					</div>
				</div>
			</div>
			<div title="个人portal定制" style="padding: 0px;">
				<div class="form-wrapper">
					<input type="hidden" id="userSettingVal"
						value="<s:property value="userSetting.PORLETS" />" />
					<form id="portalform" method="post">
						<table class="table-03">
							<tr>
								<td colspan="6">
									设置布局
								</td>
							</tr>
							<tr>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="1"
											style="cursor:hand" id="edit_this_tab_layoutimg_1"
											swap="/portal/nresources/basd/layout/1column_1_highlight.gif"
											src="/portal/nresources/basd/layout/1column_1.gif" />
									</a>
								</td>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="2"
											style="cursor:hand" id="edit_this_tab_layoutimg_2"
											swap="/portal/nresources/basd/layout/2column_1_highlight.gif"
											src="/portal/nresources/basd/layout/2column_1.gif" />
									</a>
								</td>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="3"
											style="cursor:hand" id="edit_this_tab_layoutimg_3"
											swap="/portal/nresources/basd/layout/2column_2_highlight.gif"
											src="/portal/nresources/basd/layout/2column_2.gif" />
									</a>
								</td>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="4"
											style="cursor:hand" id="edit_this_tab_layoutimg_4"
											swap="/portal/nresources/basd/layout/2column_3_highlight.gif"
											src="/portal/nresources/basd/layout/2column_3.gif" />
									</a>
								</td>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="5"
											style="cursor:hand" id="edit_this_tab_layoutimg_5"
											swap="/portal/nresources/basd/layout/3column_1_highlight.gif"
											src="/portal/nresources/basd/layout/3column_1.gif" />
									</a>
								</td>
								<td>
									<a rel="layoutset"><img style="padding-right: 8px;" val="6"
											style="cursor:hand" id="edit_this_tab_layoutimg_6"
											swap="/portal/nresources/basd/layout/3column_2_highlight.gif"
											src="/portal/nresources/basd/layout/3column_2.gif" />
									</a>
								</td>
							</tr>
							<tr>
								<td colspan="6">
									选择模块
								</td>
							</tr>
							<tr>
								<td colspan="6">
									<s:iterator var="porlet" value="userPorlets">
										<input name="porletId" type="checkbox"
											value="<s:property value="#porlet.PORLET_ID"/>" />
										<s:property value="#porlet.TITLE" />
									</s:iterator>
								</td>
							</tr>
							<tr>
								<td colspan="6">
									菜单样式(更改后下次登录生效)
								</td>
							</tr>
							<tr >
								<td colspan="3" >
									<s:if test='%{theForm.menuType==1}'>
										<input name="menuType" type="radio" value="1" checked="checked"/>树形(旧)
									</s:if>
									<s:else>
										<input name="menuType" type="radio" value="1" />树形(旧)
									</s:else>
								</td>
								<td colspan="3" >
									<s:if test='%{theForm.menuType==2}'>
										<input name="menuType" type="radio" value="2" checked="checked"/>平铺(新)
									</s:if>
									<s:else>
										<input name="menuType" type="radio" value="2" />平铺(新)
									</s:else>
								</td>
							</tr>
						</table>
					</form>
					<div class="block03">
						<a id="portal-submit" href="javascript:void(0)"
							class="easyui-linkbutton">提交</a>
						<a id="portal-reset" href="javascript:void(0)"
							class="easyui-linkbutton">重置</a>
					</div>
				</div>
			</div>
			<div title="消息设置" style="padding: 0px;">
				<div class="form-wrapper">
					<form id="msgDisplayform" method="post">
						<table class="table-03">
							<tr>
								<td style="width:100px;height:35px">
									提示方式
								</td>
								<td>
									手动<input type="radio" value="0" name="theForm.display_type" rel='displayType' style="margin-right:20px;margin-left:5px" />自动<input type="radio" value="1" style="margin-right:20px;margin-left:5px" name="theForm.display_type" rel='displayType' />
									<span rel="display-interval" style="display:none;">间隔</span>
									<select rel="display-interval" name="theForm.display_interval" id="displayInterval" style="margin-left:5px;display:none;width:70px">
										<option value="1">1分钟</option>
										<option value="5">5分钟</option>
										<option value="10">10分钟</option>
										<option value="15">15分钟</option>
										<option value="30">30分钟</option>
										<option value="45">45分钟</option>
										<option value="60">1小时</option>
									</select>
								</td>
							</tr>
							<tr>
								<td style="width:100px">
									提示次数
								</td>
								<td>
									
									<a href="#" title="提示次数达到您设置的次数后，消息将不再重复提示;" class="easyui-tooltip">
										<input type="text" id="displaySum" name="theForm.display_sum" value="1" readonly="readonly" style="width:20px"/>
									</a>
									<a name="subtract" rel="displaySum" default="1" style="margin-left:0px;font-size:18">-</a>
									<a name="add" rel="displaySum" default="1" style="margin-left:0px;font-size:14">+</a>
								</td>
							</tr>
							<tr>
								<td style="width:100px">
									提示范围
								</td>
								<td>
									<a href="#" title="举例:<br/>值为0,代表只显示当天的消息;<br/>值为1,显示前一天到当天的消息;" class="easyui-tooltip">
									<input type="text" id="displayScope" name="theForm.display_scope" value="0" readonly="readonly" style="width:20px"/>
									</a>
									<a name="subtract" rel="displayScope" default="0" style="margin-left:0px;font-size:18">-</a>
									<a name="add" rel="displayScope" default="0" style="margin-left:0px;font-size:14">+</a>
								</td>
							</tr>
						</table>
					</form>
					<div class="block03">
						<a id="msg-submit" href="javascript:void(0)"
							class="easyui-linkbutton">提交</a>
						<a id="msg-reset" href="javascript:void(0)"
							class="easyui-linkbutton">重置</a>
					</div>
				</div>
			</div>
			
		</div>
	</body>
</html>
